/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package schoolMatSupport;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;

/**
 *
 * @author buben
 */
public class PropertyLoader {
    
    private String serverPath;
    private static PropertyLoader instance;

    private PropertyLoader(String serverPath) {
        this.serverPath = serverPath;
    }
    
    public String getProperty(String property) {
        Properties readPr = new Properties();
        try {
            readPr.load(new FileInputStream(serverPath + "WEB-INF/config.properties"));
        } catch (FileNotFoundException ex) {
            System.out.println(ex.getMessage());
        } catch (IOException ex) {
            System.out.println(ex.getMessage());
        }
        return readPr.getProperty(property);
    }
    
    public static PropertyLoader getInstance(String serverPath){
        if (instance == null){
            instance = new PropertyLoader(serverPath);
        } 
        return instance;
    }
    
}
